package com.nimitz.web.controller.pollution;

import com.nimitz.common.core.domain.AjaxResult;
import com.nimitz.system.domain.SysDirtyWater;
import com.nimitz.system.service.SysDirtyWaterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/pollution/sysDirtyWater")
public class SysDirtyWaterController {
 @Autowired
    private SysDirtyWaterService sysDirtyWaterService;

 @PostMapping
    public AjaxResult addSysDirtyWater(SysDirtyWater sysDirtyWater){
     return AjaxResult.success(sysDirtyWaterService.add(sysDirtyWater));
 }

@GetMapping
    public AjaxResult list(){
     List<SysDirtyWater> sysDirtyWater = sysDirtyWaterService.findById();
     return AjaxResult.success(sysDirtyWater);
 }

@PutMapping
    public AjaxResult update(@RequestBody @Validated({SysDirtyWater.Update.class}) SysDirtyWater sysDirtyWater){
    try {
        sysDirtyWaterService.update(sysDirtyWater);
        return AjaxResult.success();
    } catch (Exception e) {
        return AjaxResult.fail("更新失败");
    }
}
}
